//
//  ClubBillDetailVC.m
//  SelfDrivingTravelling-IOS
//
//  Created by Teplot_01 on 16/8/30.
//  Copyright © 2016年 Teplot_01. All rights reserved.
//

#import "ClubBillDetailVC.h"
#import "ClubBillDetailCell.h"
@interface ClubBillDetailVC ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation ClubBillDetailVC
{
    UITableView *_tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = White_Color;
    self.title = @"活动账单详情";
    if (self.arr.count != 0) {
        [self initTopView];
    }else{
        [SVProgressHUD showImage:nil status:@"此活动暂无账单记录"];
    }
    [self initTableView];
    _tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
}
- (void)initTopView{
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 64, KScreenWidth, 77)];
    topView.backgroundColor = superBackgroundColor;
    [self.view addSubview:topView];
    UILabel *nameLb = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-100)/2, 0, 100, 25)];
    nameLb.text = self.activityName;
    nameLb.textColor = Theme_Color;
    nameLb.font = [UIFont systemFontOfSize:14];
    nameLb.textAlignment = NSTextAlignmentCenter;
    [topView addSubview:nameLb];
    UILabel *lenderLb = [[UILabel alloc]initWithFrame:CGRectMake(40, 15, 100, 25)];
    lenderLb.text = [NSString stringWithFormat:@"%@%@",@"领队:",self.leaderName];
    lenderLb.textColor = Gray_Color;
    lenderLb.font = [UIFont systemFontOfSize:13];
    [topView addSubview:lenderLb];
    UILabel *beginTimLb = [[UILabel alloc]initWithFrame:CGRectMake(40, 45, 140, 25)];
    beginTimLb.text = [NSString stringWithFormat:@"%@%@",@"开始日期:",self.beganTime];
    beginTimLb.textColor = Gray_Color;
    beginTimLb.font = [UIFont systemFontOfSize:13];
    [topView addSubview:beginTimLb];
    UILabel *moneyLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - 160, 15, 120, 25)];
    NSString *money = [NSString stringWithFormat:@"%@%@%@", @"金额:", self.totalMoney,@"元"];
    moneyLb.text = money;
    moneyLb.textColor = Gray_Color;
    moneyLb.textAlignment = NSTextAlignmentRight;
    moneyLb.font = [UIFont systemFontOfSize:13];
    [topView addSubview:moneyLb];
    UILabel *endTimLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - 180, 45, 140, 25)];
    endTimLb.text = [NSString stringWithFormat:@"%@%@",@"结束日期:",self.endTime];
    endTimLb.textColor = Gray_Color;
    endTimLb.textAlignment = NSTextAlignmentRight;
    endTimLb.font = [UIFont systemFontOfSize:13];
    [topView addSubview:endTimLb];
}
- (void)initTableView{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(10, 141, KScreenWidth - 20, KScreenHeight - 64)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
}
#pragma - mark UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arr.count+1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 35;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        UITableViewCell *cell = [[UITableViewCell alloc]init];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (self.arr.count != 0) {
            UILabel *IdLb = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 50, 35)];
            IdLb.text = @"姓名";
            IdLb.textColor = Theme_Color;
            IdLb.font = [UIFont systemFontOfSize:13];
            [cell.contentView addSubview:IdLb];
            UILabel *memberLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth/2-35, 0, 50, 35)];
            memberLb.text = @"成员";
            memberLb.textAlignment = NSTextAlignmentCenter;
            memberLb.textColor = Theme_Color;
            memberLb.font = [UIFont systemFontOfSize:13];
            [cell.contentView addSubview:memberLb];
            UILabel *totalLb = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - 60, 0, 30, 35)];
            totalLb.text = @"金额";
            totalLb.textAlignment = NSTextAlignmentRight;
            totalLb.textColor = Theme_Color;
            totalLb.font = [UIFont systemFontOfSize:13];
            [cell.contentView addSubview:totalLb];
        }
        
        return cell;
    }else{
        ClubBillDetailCell *cell = [[NSBundle mainBundle]loadNibNamed:@"ClubBillDetailCell" owner:nil options:nil][0];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.memberLb1.text = self.arr[indexPath.row-1][@"payerName"];
        cell.IdName.text = self.arr[indexPath.row-1][@"payerName"];
        NSNumber *num = self.arr[indexPath.row-1][@"money"];
        cell.memberSpenLb1.text = num.stringValue;
        return cell;
    }
    return nil;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
